package org.jeecg.modules.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.jeecg.modules.system.entity.BdCityEntity;
import org.jeecg.modules.system.entity.BizSiteEntity;

import java.util.List;
import java.util.Map;

public interface BizSiteMapper extends BaseMapper<BizSiteEntity> {

    @Select(" select '2' status, count(1) count from biz_site c where c.status=1 and exists(select 1 from biz_equipment a, biz_equipment_state b " +
            "   where a.eq_id=b.eq_id and a.status=1 and b.status in (2,3,4) and c.site_id=a.site_id) " +
            "union " +
            "select '1' status, count(1) count from biz_site c " +
            "   where c.status=1 and not exists(select 1 from biz_equipment a, biz_equipment_state b where a.status=1 and a.eq_id=b.eq_id and b.status in (2,3,4) and c.site_id=a.site_id)  ")
    List<Map<?,?>> getStatusCount();
}
